package it.antonio.ilpizze.mock;

import java.lang.reflect.Method;

public class RegisteredInvocation {

	private Object mock;
	private Method method;
	private Object[] arguments;
	private Object returnValue;
	private Throwable exception;
	private boolean hasMatchers;
	private boolean throwsException;
	
	public RegisteredInvocation(Object mock, Method method, Object[] arguments, Object returnValue, Throwable exception) {
		this.mock = mock;
		this.method = method;
		this.arguments = arguments;
		this.returnValue = returnValue;
		this.exception = exception;
		this.hasMatchers = arguments != null && arguments.length > 0 && isMatcher(arguments[0]); 
		this.throwsException = exception != null;
	}

	private static boolean isMatcher(Object argument){
		return (argument instanceof ArgumentMatcher);
	}

	public Object mock() {
		return mock;
	}

	public Method method() {
		return method;
	}

	public Object[] arguments() {
		return arguments;
	}

	public Object returnValue() {
		return returnValue;
	}

	public Throwable exception() {
		return exception;
	}

	public boolean hasMatchers() {
		return hasMatchers;
	}

	public boolean throwsException() {
		return throwsException;
	}
	
	
}